﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace roma
{
    public partial class Title : Form
    {
        /*属性*/
        //judge_if_once_numberous为string类型的判断单次或多次的变量
        public string judge_if_once_numberous = null;
        /*类的引用*/
        Basefunction function = new Basefunction();
        Tips error = new Tips();
        State state = new State();
        public Title()
        {
            InitializeComponent();
        }

        private void once_CheckedChanged(object sender, EventArgs e)
        {
            //调用function类的once_number_checkchanged方法，转换为单次转换方式
            judge_if_once_numberous = function.once_number_checkchanged("once");
        }

        private void numberous_CheckedChanged(object sender, EventArgs e)
        {
            //调用function类的once_number_checkchanged方法，转换为批量转换方式
            judge_if_once_numberous = function.once_number_checkchanged("numberous");
        }

        private void turn_button_Click(object sender, EventArgs e)
        {
            clean_showlabel();
            turn_tojudge();
            clean_textbox();
        }
        private void out_button_Click(object sender, EventArgs e)
        {
            function.OpenOrCreateFile(out_address.Text,"Roma_output");
        }

        private void explain_button_Click(object sender, EventArgs e)
        {
            function.OpenOrCreateFile(out_address.Text, "code_explain");
        }

        private void help_button_Click(object sender, EventArgs e)
        {
            function.OpenOrCreateFile(out_address.Text, "code_userhelp");
        }

        private void infoset_button_Click(object sender, EventArgs e)
        {
            function.OpenOrCreateFile(out_address.Text, "exe_infoset");
        }

        private void clean_showlabel()
        {
            showlabel.Text = state.null_state();
        }
        
        private void clean_textbox()
        {
            number_input.Text = state.null_state();
        }
        private void state_tochange(string turn_tojudge)
        {
            warning_1.Text = state.null_state();
            warning_2.Text = state.warning_state();
            warning_3.Text = turn_tojudge;
        }
        private void state_normal()
        {
            warning_1.Text = state.normal_state();
            warning_2.Text = state.null_state();
            warning_3.Text = state.null_state();
        }
        private void turn_tojudge()
        {
            string turn_tojudge = function.turn_function(number_input.Text, judge_if_once_numberous,out_address.Text,"roma_output");
            if (turn_tojudge == "1000" || turn_tojudge == "1001" || turn_tojudge == "1002" || turn_tojudge == "1003")
                state_tochange(turn_tojudge);
            else
            {
                showlabel.Text = "阿拉伯数字:\n" + number_input.Text + "\n" + "转化后的罗马数字为:\n" + turn_tojudge;
                state_normal();
            }
        }

    }
}
